#define _CRT_SECURE_NO_WARNINGS	

#include<stdio.h>

int main()
{
    int n;
    scanf("%d", &n);
    int count = 0;
    for (int i = n; i <= n + 3; i++)
    {
        for (int j = n; j <= n + 3; j++)
        {
            for (int k = n; k <= n + 3; k++)
            {
                if (i != j && i != k && k != j)
                {
                    printf("%-6d", i * 100 + j * 10 + k);
                    count++;
                    if (count % 6 == 0)
                        printf("\n");
                }
            }
        }
    }
    return 0;
}